package com.qf.mapper;

import com.qf.model.Device;
import com.qf.model.DeviceType;
import com.qf.model.Farm;
import com.qf.model.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface DeviceTypeMapper {

//    @ResultMap("DeviceTypeMap")
    @Select("select * from device_type")
    List<DeviceType> getAll();

    @Results(id = "DeviceTypeMap",value = {
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "description",property = "description"),
            @Result(column = "createtime",property = "createtime"),
            @Result(column = "updatetime",property = "updatetime"),
    })

    @Select("select * from device_type limit #{currentPage},#{pageSize}")
    List<DeviceType> findPage(@Param("currentPage") Integer currentPage,@Param("pageSize") Integer pageSize);

    @Select("select count(*) from device_type")
    long count();

    @Insert("insert into device_type (name,description,createtime,updatetime) values (#{name},#{description},#{createtime},#{updatetime})")
    int insertDeviceType(DeviceType deviceType);

    @ResultMap("DeviceTypeMap")
    @Select("select * from device_type where id =#{id}")
    DeviceType findDeviceType(int id);

    @Update("update device_type set name=#{name},description=#{description},createtime=#{createtime},updatetime=#{updatetime} where id=#{id}")
    int update(DeviceType deviceType);

    @Delete("delete from device_type where id =#{id}")
    int delDeviceType(Integer id);
}
